
package com.wit.witmg.util;

import lombok.Data;

import java.io.Serializable;

/**
 * JSON回应类,包含总条数
 *
 */
@Data
public class JsonListResult implements Serializable {

    private Integer result = 1;// 1成功，-1失败
    private Integer code=0;//错误码
    private Object message = "成功";  // 提示语
    private long total;// 数据总数
    /**
     * 构造函数
     */
    private JsonListResult() {
    }


    private JsonListResult(Object message, long total) {
        this.message = message;
        this.total=total;
    }


    private JsonListResult(Integer code, String msg) {
        this.code = code;
        this.message = msg;
    }

    public static JsonListResult success() {
        return new JsonListResult();
    }

    public static JsonListResult success(Object msg,long total) {
        return new JsonListResult(msg,total);
    }


    public static JsonListResult error(ErrorCode errorCode) {
        return new JsonListResult(errorCode.getCode(), errorCode.getMsg());
    }


}
